<template>
  <el-container id="app">
    <el-header>
      <AppHeader/>
    </el-header>
    <el-container>
      <el-aside :width="asideCollapse ? '82px' : '341px'">
        <AppAside/>
      </el-aside>
      <el-container>
        <el-main class="main">
          <transition
            name="no-mode-translate-fade"
            @before-enter="beforeEnter"
            @after-leave="afterLeave"
          >
            <keep-alive>
              <router-view/>
            </keep-alive>
          </transition>
          <!-- <AppFooter/> -->
        </el-main>
        <!-- <el-footer>
          <AppFooter/>
        </el-footer>-->
      </el-container>
    </el-container>
  </el-container>
</template>

<script>
import { mapState } from 'vuex'
// @ is an alias to /src
import AppHeader from "@/components/layout/AppHeader.vue";
import AppAside from "@/components/layout/AppAside.vue";
import AppFooter from "@/components/layout/AppFooter.vue";

export default {
  name: "App",
  components: {
    AppAside,
    AppFooter,
    AppHeader
  },
  computed: mapState([
    // 映射 this.count 为 store.state.count
    "asideCollapse"
  ]),
  methods: {
    beforeEnter: function() {
      document.getElementsByTagName("html")[0].style.overflow = "hidden";
    },
    afterLeave: function() {
      document.getElementsByTagName("html")[0].style.overflow = "initial";
    }
  }
};
</script>


<style>
html {
  height: 100%;
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}
body {
  overflow: hidden; /* 动画执行的时候回出现滚动条 */
  padding: 0;
  margin: 0;
  height: 100%;
  min-height: 100%;
}
.no-mode-translate-fade-enter-active,
.no-mode-translate-fade-leave-active {
  transition: all 1s;
  position: absolute;
  width: calc(100% - 40px);
}
.no-mode-translate-fade-enter,
.no-mode-translate-fade-leave-active {
  opacity: 0;
}
.no-mode-translate-fade-enter {
  transform: translateX(20px);
}
.no-mode-translate-fade-leave-active {
  transform: translateX(-20px);
}
</style>

<style lang="less">
#app {
  height: 100%;
  & > .el-container {
    height: 100%;
    & > .el-aside {
      margin-right: -17px;
      margin-bottom: -17px;
      overflow: scroll;
      background-color: #545c64; // 和AppAside 里面el-menu组件的背景色相同
      transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    }
    & > .el-container {
      position: relative;
      z-index: 1;
      background: #fff;
    }
    .el-menu {
      border-right: solid 1px #545c64;
    }
  }
}
</style>

<style scoped lang="less">
.main {
  padding-bottom: 100px;
}
</style>
